using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Windows.Forms;
using ZoneFiveSoftware.Common.Visuals;

namespace BENBUN.ExportCRS
{
    internal class OptionsPage : ISettingsPage {
        #region ISettingsPage Members

        public Guid Id {
            get { return new Guid("9efa6d14-d89d-4929-8fde-35f7720530af"); }
        }

        public IList<ISettingsPage> SubPages {
            get { return null; }
        }

        public string PageName {
            get { return "Export CRS Settings"; }
        }

        public string Title {
            get { return PageName; }
        }

        public Control CreatePageControl() {
            CreateControl();
            return control;
        }

        public IPageStatus Status {
            get {
                if (control != null) {
                    return control.Status;
                }
                return null;
            }
        }

        public bool Modified {
            get {
                if (control != null) {
                    return control.Modified;
                }
                return false;
            }
        }

        public void ShowPage(string bookmark) {
            if (control != null) {
                control.ShowPage(bookmark);
            }
        }

        public bool HidePage() {
            if (control != null) {
                return control.HidePage();
            }
            return true;
        }

        public void ThemeChanged(ITheme visualTheme) {
            if (control != null) {
                control.ThemeChanged(visualTheme);
            }
        }

        public void UICultureChanged(CultureInfo culture) {
            if (control != null) {
                control.UICultureChanged(culture);
            }
        }

        #endregion

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        #region Private methods

        private void CreateControl() {
            if (control != null) {
                return;
            }
            
            control = new OptionsView();
            control.PropertyChanged += new PropertyChangedEventHandler(control_PropertyChanged);
        }

        private void OnPropertyChanged(string propertyName) {
            if (PropertyChanged != null) {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        private void control_PropertyChanged(object sender, PropertyChangedEventArgs e) {
            OnPropertyChanged(e.PropertyName);
        }

        #endregion

        #region Private members

        private OptionsView control = null;

        #endregion
    }
}